package com.example.myapplication2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    public Button btn;
    public TextView zcc;
    public EditText username;
    public EditText password;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn =  findViewById(R.id.btn);
        zcc = findViewById(R.id.zcc);
        username = findViewById(R.id.username);
        password = findViewById(R.id.password);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String u = username.getText().toString();
                String p = password.getText().toString();
                if(u.equals("")||p.equals("")){
                    Toast.makeText(MainActivity.this, "请输入完整信息", Toast.LENGTH_SHORT).show();
                }else{
                    if(u.equals("123") && p.equals("123")){
                        Toast.makeText(MainActivity.this, "登陆成功", Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(MainActivity.this, ThirdActivity.class);
                        startActivity(intent);
                    }else{
                        Toast.makeText(MainActivity.this, "登录失败，请检查用户名和密码是否正确", Toast.LENGTH_SHORT).show();
                    }
                }

            }
        });
        zcc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, SecondActivity.class);
                startActivity(intent);
            }
        });
    }
}